import React from 'react';

export interface ITextProps {
  type?: 'help' | 'link'; // 文本类型
  title?: boolean | 'lg' | 'sm'; // 标题大小
  bold?: boolean;
  color?: 'highlight' | 'secondary' | 'warn' | 'success'; //
  ellipsis?: boolean;
}

export default class Text extends React.Component<ITextProps> {
  public render() {
    const { type, title, color, bold, ellipsis } = this.props;
    const classNames = ['text'];
    if (type) {
      classNames.push('text-' + type);
    }
    if (title) {
      classNames.push('title');
      if (title !== true) {
        classNames.push('title-' + title);
      }
    }
    if (color) {
      classNames.push('text-' + color);
    }
    if (ellipsis) {
      classNames.push('text-ellipsis');
    }
    if (bold) {
      classNames.push('text-bold');
    }
    return (
      <span className={classNames.join(' ')}>{this.props.children}</span>
    );
  }
}
